package data;

import anaydis.sort.data.DataSetGenerator;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Keevu
 * Date: 17/08/11
 * Time: 15:42
 * To change this template use File | Settings | File Templates.
 */
public class IntegerDataSetGenerator implements DataSetGenerator<Integer> {

    @NotNull
    public List<Integer> createAscending(int i) {
        List<Integer> ls = new ArrayList();
        for (int w = 0; w < i; w++) {
            ls.add(w);
        }
        return ls;

    }

    @NotNull
    public List<Integer> createDescending(int i) {
        List<Integer> ls = new ArrayList();
        for (int w = 0; w < i; w++) {
            ls.add(i - w);
        }
        return ls;
    }

    @NotNull
    public List<Integer> createRandom(int i) {
        List<Integer> ls = new ArrayList();
        for (int w = 0; w < i; w++) {
            ls.add((int) (Math.random() * (i + 1)));
        }
        return ls;
    }

    @NotNull
    public Comparator<Integer> getComparator() {
        return new Comparator<Integer>() {
            public int compare(Integer integer, Integer integer1) {
                if (integer > integer1) {
                    return 1;
                }
                if (integer < integer1) {
                    return -1;
                } else {
                    return 0;
                }
            }
        };
    }
}

